package com.burgeon.backend.Rest.Template.Reviews;
/**
 * test
 */

import com.burgeon.backend.Rest.base.RESTBase;
import org.json.JSONArray;
import org.springframework.util.MultiValueMap;

import java.util.ArrayList;
import java.util.HashMap;

public class demo extends RESTBase {

    private String ip;
    private String account;
    private String password;

    public demo(String ip, String account, String password) {
        this.ip = ip;
        this.account = account;
        this.password = password;
    }

    /**
     * 发送并接收字符创
     */

    public Integer getData(String id) throws Exception {
        String url = "http://" + ip + "/servlets/binserv/Rest";
        String str = RESULT(Data(id), url);

        String code = new JSONArray(str).getJSONObject(0).getString("code");

        if (!"0".equals(code)) {
            throw new Exception(str);
        }

        return null;

    }

    private MultiValueMap Data(String id) {
        HashMap params = new HashMap();
        ArrayList columns = new ArrayList();//查询字段
        columns.add("ID");
        columns.add("NAME");

        params.put("columns", columns);
        params.put("table", "C_VIP");//表名


        params.put("count", "true");
        HashMap paramss = new HashMap();
        String ac = "\"IN ('15081953613','15232621562')\"";
        paramss.put("column", "'CARDNO'");
        paramss.put("condition", ac);//查询条件

        params.put("params", paramss);


        return DATA("Query", params, account, password);
    }

    public static void main(String[] args) {
        demo g = new demo("59.110.28.94:90", "nea@burgeon.com.cn", "burgeon55321");
        try {

            System.err.println(g.getData("43"));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
